<template>
	<view>

		<view class="center switch-city-con">
			<view class="city-location">
				<view class="loca-name">杭州</view>
			</view>

			<view class="last-visit">
				<view class="visit-tit">最近访问</view>
				<view class="visit-con">
					<span>{{city_name}}</span>
				</view>
			</view>

			<view v-for="(item,index ) in city" :key="index" class="city-list-wrap">
				<view class="part-box">
					<view class="part-tit">{{item.alias}}</view>
					<ul class="part-con">
						<li @click="goToCity(item2.id,item2.name)" v-for="(item2,index2 ) in item.city" :key="index2">
							<p>{{item2.name}}</p>
						</li>
					</ul>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
export default {
  data() {
    return {
		city:[],
		city_name:'杭州'
	};
  },
  onLoad() {
	let city_name = this.$db.get('city_name');
	  if(city_name){
		  this.city_name = city_name;
	  }
	  
  	this.$api.getCity({
  		},
  		res => {
  			this.city = res.city;
			console.log(this.city)
  		}
  	);
  },
  methods: {
	  goToCity(city_id,city_name){
		this.$db.set('cityId', city_id);
		this.$db.set('city_name', city_name);
		/* uni.switchTab({
			url: '../index',
			success(){
				let page = getCurrentPages().pop(); //跳转页面成功之后
				 if (!page) return;  
				 page.onLoad(); //重新刷新页面
			}
		}); */
		this.$common.navigateTo("/pages/index/index")
	  }
  },
};
</script>

<style scoped>
	*{
		margin: 0 ;
		padding: 0;
		list-style: none;
	}


	.center{
		/* margin: 0 40upx 0 40upx; */
	}
	.city-location,.last-visit,.part-con{
		background: #fff;
	}
	.city-location{
		height: 104upx;
	}
	.loca-name{
		line-height: 104upx;
		color: #031a1f;
		margin: 0 40upx 0 40upx;
		border-bottom: 2upx solid #f6f6f6;
		font-size: 32upx;
		font-weight: 550;
	}
	.last-visit{
		padding-top: 20upx;
		margin-top: 2upx;
	}
	.visit-tit{
		color: #031a1f;
		font-size: 32upx;
		margin: 14upx 40upx 20upx 40upx;
	}
	.visit-con{
		padding:20upx 0 40upx 0;
		margin-left: 40upx;
	}
	.visit-con>span{
		border: 1upx solid #cdd7e1;
		padding: 12upx 48upx;
		font-size: 28upx;
		border-radius: 6upx;
		box-shadow:0 .40upx 12upx rgba(224, 220, 220, 0.5)
	}

	.part-tit{
		height: 51.2upx;
		margin-left: 40upx;
		font-weight: 700;
		color: #031a1f;
		background: #f3f6f9;
		line-height: 51.2upx;
	}	

	.part-con>li{
		height: 96upx;
		margin-left: 40upx;
		margin-right: 40upx;
		font-size: 32upx;
		line-height: 96upx;
		border-bottom: 2upx solid #f6f6f6;
	}

</style>
